package polymorphism;

class Animal{
    public void eat(){
        System.out.println("动物 ：吃");
    }

    public void shout() {
        System.out.println("动物 ：叫");
    }
}

class Dog extends Animal{
    public void eat(){
        System.out.println("狗吃骨头");
    }

    public void shout(){
        System.out.println("汪！汪！汪！");
    }
}

class Cat extends Animal{
    public void eat(){
        System.out.println("猫抓老鼠");
    }

    public void shout(){
        System.out.println("喵！喵！喵！");
    }
}

public class AnimalTest {
    public void func(Animal animal){
            animal.eat();
            animal.shout();
    }

    public static void main(String[] args) {
        AnimalTest test = new AnimalTest();
        test.func(new Animal());

        System.out.println("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~");

        test.func(new Dog());
        test.func(new Cat());
    }
}
